package com.iot.apicontrol.mapper;

import com.iot.apicontrol.dto.Dc3ApiControlDto;
import com.iot.apicontrol.pojo.Dc3ApiControl;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

/**
 * @Author 咕唧
 * @Date 2022/7/22 11:09
 * @Version 1.0
 */
public interface Dc3ApiMapper {
    @SelectKey(statement = "select replace(UUID(),'-','')", keyProperty = "id", before = true, resultType = String.class)
    @Insert("insert into dc3_api_control(id,api,description) values (#{id},#{api},#{description})")
    void addApi(Dc3ApiControl dc3ApiControl);

    @Select("select api,description from dc3_api_control where enable = 1")
    List<Dc3ApiControlDto> findAllApi2Dto();

    @Delete("update dc3_api_control set enable = 0,deleted = 1 where id = #{id}")
    Long deleteApiById(String id);
}
